import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
      home: Scaffold(
    appBar: AppBar(
      title: const Text("你好flutter"),
    ),
    body: const MyApp(),
  )));
}

const List<Widget> dataList = [
  IconButton(
    icon: Icons.shop,
    color: Colors.lightBlue,
  ),
  IconButton(
    icon: Icons.house,
    color: Colors.lightGreen,
  ),
  IconButton(
    icon: Icons.fire_truck,
    color: Colors.red,
  ),
  IconButton(
    icon: Icons.settings,
    color: Colors.orange,
  ),
  IconButton(
    icon: Icons.logout,
    color: Colors.cyan,
  ),
  IconButton(
    icon: Icons.star,
    color: Colors.yellow,
  ),
  IconButton(
    icon: Icons.delete,
    color: Colors.lightGreen,
  ),
  IconButton(
    icon: Icons.rule,
    color: Colors.lightBlue,
  ),
  IconButton(
    icon: Icons.timeline,
    color: Colors.lightGreen,
  ),
  IconButton(
    icon: Icons.access_alarm,
    color: Colors.lightBlue,
  ),
];

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return GridView.builder(
      itemCount: 10,
      padding: const EdgeInsets.all(10),
      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 4,
        mainAxisSpacing: 10,
        crossAxisSpacing: 10,
      ),
      itemBuilder: (context, index) {
        return dataList[index];
      },
    );
  }
}

class IconButton extends StatelessWidget {
  final Color color;
  final double size;
  final IconData icon;
  const IconButton(
      {super.key,
      required this.icon,
      this.color = Colors.blue,
      this.size = 32.0});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 100.0,
      width: 100.0,
      color: color,
      child: Center(
        child: Icon(icon, size: size, color: Colors.white),
      ),
    );
  }
}
